<?
require '../inc.php';
$act = $_REQUEST['act'];
$ourl = $_REQUEST['ourl']?$_REQUEST['ourl']:surl::get('www').'register.php?step03';
$eurl = $_REQUEST['eurl']?$_REQUEST['eurl']:surl::get('www').'register.php?step02';
switch($act)
{
	case 'reg':
		$urs = $_POST['urs'];
		$pwd = $_POST['pwd'];
		$mail = $_POST['mail'];
		$authimg = $_POST['authimg'];
		$authimg_idcode = $_COOKIE['idcode'];
		if($authimg && $authimg_idcode && authimg::de($authimg_idcode) == $authimg)
		{
			$db_member 	= new db($scfg['db']['member']);
			$rs  		= u::reg($urs,$pwd,$mail);
			if($rs[0])
			{
				$rs = u::login($urs,$pwd);
				if($rs[0])
				{
					$bind = array(
						'time'=>time(),
						'username'=>$rs[2]['urs'],
						'password'=>$rs[2]['pwd'],
						'email'=>$rs[2]['mail'],
					);
					dzapi::login($bind,$ourl);
					//g::gowin($ourl);
				}else
				{
					echo g::msg($rs[1]);
					g::gowin($eurl);
				}
			}else
			{
				echo g::msg($rs[1]);
				g::gowin($eurl);
			}
		}else
		{
			echo g::msg("提示:验证码有误请认真输入!");
			g::gowin($eurl);
		}
	break;
	case 'regChk':
		$urs 		= $_GET['urs'];
		$db_member 	= new db($scfg['db']['member']);
		$rs 		= u::regChk($urs);
		echo json::flush($rs);	
	break;
	default:
		g::gowin($eurl);
	break;
}
?>